package com.water.camera.mark;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.water.camera.bean.EditItem;
import com.water.camera.databinding.LayoutWatermark78Binding;

import java.text.SimpleDateFormat;
import java.util.ArrayList;

public class Mark78 extends BaseMark {

    LayoutWatermark78Binding binding;

    public Mark78(@NonNull Context context) {
        super(context);
    }

    public Mark78(@NonNull Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    public Mark78(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    protected void init(int type) {
        if (type == 0) {
            binding = LayoutWatermark78Binding.inflate(LayoutInflater.from(getContext()));
            addView(binding.getRoot());
            hideView(binding.item65Recycler);
        } else {
            binding = LayoutWatermark78Binding.inflate(LayoutInflater.from(getContext()), this, true);
        }
        update();
    }

    @Override
    public void update() {
        setText(binding.item65Title, "title78", binding.item65Title);
        setText(binding.item65Time, "time78", binding.item65Con);
        setTime(binding.item65Time, new SimpleDateFormat("HH:mm"));
        setTime(binding.item65Date, new SimpleDateFormat("yyyy-MM-dd"));
        setWeek(binding.item65Week);

        setText(binding.binding6, "weather78", binding.binding5);
        setText(binding.binding8, "jingwei78", binding.binding7);

        setText(binding.binding10, "area78", binding.binding9);
        setText(binding.binding12, "content78", binding.binding11);

        setText(binding.binding14, "worker78", binding.binding13);
        setText(binding.binding16, "work78", binding.binding15);
        setText(binding.binding18, "build78", binding.binding17);
        setText(binding.binding20, "check78", binding.binding19);
        setText(binding.binding22, "beizhu78", binding.binding21);
        setText(binding.binding24, "didian78", binding.binding23);

        super.update();
    }

    @Override
    public ArrayList<EditItem> getEditItems() {
        ArrayList<EditItem> list = new ArrayList<>();
        list.add(new EditItem("title78", "标题"));
        list.add(new EditItem("time78", "时间", true));
        list.add(new EditItem("weather78", "天气"));
        list.add(new EditItem("jingwei78", "经纬度"));

        list.add(new EditItem("area78", "施工区域"));
        list.add(new EditItem("content78", "施工内容"));
        list.add(new EditItem("worker78", "施工负责人"));

        list.add(new EditItem("work78", "施工单位"));
        list.add(new EditItem("build78", "建设单位"));
        list.add(new EditItem("check78", "监理单位"));
        list.add(new EditItem("beizhu78", "备注"));
        list.add(new EditItem("didian78", "地点"));

        return list;
    }

    @Override
    public void onValueChange(EditItem item) {
        if (item.isTime) {
            setTime(binding.item65Time, new SimpleDateFormat("HH:mm"));
            setTime(binding.item65Date, new SimpleDateFormat("yyyy-MM-dd"));
            setWeek(binding.item65Week);
        } else {
            super.onValueChange(item);
        }
    }
}
